function compressed = dynamicRangeCompression(X)
    isColor = size(size(X),2) > 2;
    if (isColor)
        % Ver si existe una manera de procesar todo por igual sea a color o
        % no. Se hacia dificil el manejo de la matrix de (r,c,3)
        % row,col,RGBpixels.
        [r, c] = size(X(:,:,1));
        compressed = uint8(zeros(r,c,3));
        r = double(X(:,:,1));
        g = double(X(:,:,2));
        b = double(X(:,:,3));
        max0 = [max(r(:)), max(g(:)), max(b(:))];
        c1 = (255 ./ log10(1 + max0));
        r = uint8(floor(c1(1)*(log10(1+r))));
        g = uint8(floor(c1(2)*(log10(1+g))));
        b = uint8(floor(c1(3)*(log10(1+b))));
        compressed(:,:,1) = r;
        compressed(:,:,2) = g;
        compressed(:,:,3) = b;
    else
        max0 = max((double(X(:))));
        c1 = (255 / log10(1 + max0));
        compressed = uint8(floor(c1 * log10(1+double(X))));
    end
end
